package com.gec.system.Service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gec.model.pojo.TUser;
import com.gec.model.vo.TUserQueryVo;
import com.gec.system.Service.TUserService;
import com.gec.system.mapper.TUserMapper;
import org.springframework.stereotype.Service;


@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements TUserService {

    @Override
    public IPage<TUser> selectPage(IPage<TUser> Page, TUserQueryVo tUserQueryVo) {
        return this.baseMapper.selectPage(Page, tUserQueryVo);
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        //1.查询出当前用户
        TUser tUser = this.baseMapper.selectById(id);
        //2.设置状态
        tUser.setStatus(status);
        //3.更新
        this.baseMapper.updateById(tUser);
    }

    //yxId查询，用于验证前端随机yxId是否重复
    @Override
    public TUser getByUserId(Long yxId) {
        QueryWrapper queryWrapper = new QueryWrapper<TUser>();
        queryWrapper.eq("yx_id", yxId);
        TUser tUser = baseMapper.selectOne(queryWrapper);
        return tUser;
    }
}
